<?php

namespace Product\Model;

use Zend\Db\TableGateway\TableGateway;
use Product\Entity\Brand;


class BrandTable
{
    protected $tableGateway;
    
    public function __construct(TableGateway $tableGateway) {
        $this->tableGateway = $tableGateway;
    }
    
    public function saveBrand(Brand $brand)
    {
        $data = array(
            'name' => $brand->getName(),
            'url' => $brand->getUrl() ,
        );
        
        $id = (int)$brand->getId();
        if($id == 0)
        {  
            $this->tableGateway->insert($data);
        }       
	return $this->tableGateway->getLastInsertValue();  
    }
}
